home *** CD-ROM | disk | FTP | other *** search
/ Champak 40 / Vol 40.iso / games / 360_derg.swf / scripts / frame_1 / DoAction.as
Text File  |  2007-05-10  |  5KB  |  179 lines

  1. function move()
  2. {
  3.    var _loc1_ = _root;
  4.    posx[0] = _loc1_.snake._x;
  5.    posy[0] = _loc1_.snake._y;
  6.    _loc1_.snake._x += 4 * Math.cos(0.017453292519943295 * theta);
  7.    _loc1_.snake._y += 4 * Math.sin(0.017453292519943295 * theta);
  8.    if(_loc1_.init)
  9.    {
  10.       t = 0;
  11.       while(t < _loc1_.snakelength)
  12.       {
  13.          nn = "body" + Number(t);
  14.          duplicateMovieClip("snake",nn,16384 + t);
  15.          nn._x = -20;
  16.          nn._y = -20;
  17.          t++;
  18.       }
  19.       _loc1_.init = false;
  20.       _loc1_.specialtime.stime = 0;
  21.       _loc1_.specialtime.sout = false;
  22.       _loc1_.specialtime._visible = false;
  23.    }
  24.    _loc1_.ltf();
  25.    t = _loc1_.snakelength - 1;
  26.    while(t > 0)
  27.    {
  28.       posx[t] = posx[t - 1];
  29.       posy[t] = posy[t - 1];
  30.       t--;
  31.    }
  32.    if(collide(_loc1_.food._x,_loc1_.food._y))
  33.    {
  34.       _loc1_.foods = false;
  35.       t = 0;
  36.       while(t < 20)
  37.       {
  38.          nn = "body" + Number(_loc1_.snakelength);
  39.          duplicateMovieClip("snake",nn,16384 + _loc1_.snakelength);
  40.          nn._x = -20;
  41.          nn._y = -20;
  42.          posx[_loc1_.snakelength] = posx[_loc1_.snakelength - 1];
  43.          posy[_loc1_.snakelength] = posy[_loc1_.snakelength - 1];
  44.          _loc1_.snakelength = _loc1_.snakelength + 1;
  45.          t++;
  46.       }
  47.       t = 0;
  48.       while(t < _loc1_.snakelength)
  49.       {
  50.          nn = "body" + Number(t);
  51.          setProperty(nn, _X, posx[t]);
  52.          setProperty(nn, _Y, posy[t]);
  53.          t++;
  54.       }
  55.       _loc1_.count = 0;
  56.       _loc1_.score += 5;
  57.    }
  58.    if(collide(_loc1_.specialfood._x,_loc1_.specialfood._y))
  59.    {
  60.       _loc1_.score += Number(_loc1_.specialtime.spoints);
  61.       _loc1_.specialtime.spoints = 0;
  62.       _loc1_.specialtime.stime = 0;
  63.       _loc1_.specialfood._x = -30;
  64.       _loc1_.specialfood._y = -20;
  65.       _loc1_.specialtime.sout = false;
  66.       _loc1_.specialtime._visible = false;
  67.    }
  68.    if(_loc1_.specialtime.sout)
  69.    {
  70.       _loc1_.specialtime.stime -= 1;
  71.       _loc1_.specialtime.spoints = int(_loc1_.specialtime.stime / 10.5);
  72.       if(_loc1_.specialtime.stime == 0)
  73.       {
  74.          _loc1_.specialfood._x = -30;
  75.          _loc1_.specialfood._y = -20;
  76.          _loc1_.specialtime.sout = false;
  77.          _loc1_.specialtime._visible = false;
  78.       }
  79.    }
  80.    if(!_loc1_.foods)
  81.    {
  82.       x = random(292) + 19;
  83.       y = random(272) + 19;
  84.       _loc1_.food._x = x;
  85.       _loc1_.food._y = y;
  86.       if(_loc1_.score != 0 && (_loc1_.snakelength - 19) % 100 == 0)
  87.       {
  88.          sx = random(292) + 19;
  89.          sy = random(272) + 19;
  90.          _loc1_.specialfood._x = sx;
  91.          _loc1_.specialfood._y = sy;
  92.          _loc1_.specialtime.stime = 210;
  93.          _loc1_.specialtime.spoints = 20;
  94.          _loc1_.specialtime.sout = true;
  95.          _loc1_.specialtime._visible = true;
  96.       }
  97.       _loc1_.foods = true;
  98.    }
  99.    if(_loc1_.snake._x < 10 || _loc1_.snake._x > 310 || _loc1_.snake._y < 10 || _loc1_.snake._y > 290)
  100.    {
  101.       _loc1_.destroy();
  102.    }
  103.    t = 0;
  104.    while(t < _loc1_.snakelength)
  105.    {
  106.       if(collide(posx[t],posy[t]))
  107.       {
  108.          _loc1_.destroy();
  109.       }
  110.       t++;
  111.    }
  112. }
  113. function ltf()
  114. {
  115.    var _loc1_ = _root;
  116.    last = _loc1_.snakelength - 1 - _loc1_.count;
  117.    nn = "body" + Number(last);
  118.    _loc1_.count = _loc1_.count + 1;
  119.    if(last == 0)
  120.    {
  121.       _loc1_.count = 0;
  122.    }
  123.    setProperty(nn, _X, posx[0]);
  124.    setProperty(nn, _Y, posy[0]);
  125. }
  126. function collide(objectx, objecty)
  127. {
  128.    delta_x = _root.snake._x - objectx;
  129.    delta_y = _root.snake._y - objecty;
  130.    if(delta_x * delta_x + delta_y * delta_y < 15)
  131.    {
  132.       return true;
  133.    }
  134.    return false;
  135. }
  136. function destroy()
  137. {
  138.    var _loc1_ = _root;
  139.    _loc1_.crash._x = _loc1_.snake._x;
  140.    _loc1_.crash._y = _loc1_.snake._y;
  141.    t = 0;
  142.    while(t < _loc1_.snakelength)
  143.    {
  144.       nn = "body" + Number(t);
  145.       removeMovieClip(nn);
  146.       t++;
  147.    }
  148.    _loc1_.snake._visible = false;
  149.    _loc1_.crash.gotoAndPlay(2);
  150.    if(score > _loc1_.scoretable.topten.SCORE9)
  151.    {
  152.       gotoAndStop(5);
  153.    }
  154.    else
  155.    {
  156.       gotoAndStop(4);
  157.    }
  158. }
  159. sfile = "http://www.s4websolutions.com/rsnake/scores.php";
  160. sview = sfile + "?filename=score.sco&scoresize=10&action=VIEW&viewtype=FLASH";
  161. posx = new Array();
  162. posy = new Array();
  163. snakelength = 19;
  164. t = 0;
  165. while(t < snakelength)
  166. {
  167.    posx[t] = -20;
  168.    posy[t] = -20;
  169.    t++;
  170. }
  171. init = true;
  172. theta = 0;
  173. foods = false;
  174. score = 0;
  175. count = 0;
  176. _root.scoretable.topten.loadVariables(_root.sview);
  177. _root.scoretable._visible = false;
  178. stop();
  179.